# Contributor: Milan P. Stanić <mps@arvanta.net>
# Maintainer: Milan P. Stanić <mps@arvanta.net>
pkgname=vboot-utils
pkgver=6310032
_release=0~R63-10032.B
pkgrel=8
pkgdesc="Chromium OS vboot utilities"
url="https://github.com/coreboot/vboot"
arch="armhf armv7 aarch64 x86_64 x86"
license="custom:chromiumos"
options="!check" # test fails but package works
makedepends="yaml-dev xz-dev musl-fts-dev openssl-dev>3 util-linux-dev bash linux-headers"
subpackages="cgpt $pkgname-doc"
source="https://deb.debian.org/debian/pool/main/v/vboot-utils/vboot-utils_$_release.orig.tar.gz
	no-static.patch
	"
builddir="$srcdir"

build() {
	export CFLAGS="$CFLAGS -D_GNU_SOURCE -Wno-error -fcommon"
	local _arch=$CARCH
	case "$CARCH" in
		arm*|aarch64) _arch=arm;;
	esac
	make ARCH=$_arch MINIMAL=1 V=1 cgpt utils futil
}

package() {
	make DESTDIR="$pkgdir"/usr install
	install -d "$pkgdir"/usr/share/vboot/
	cp -r tests/devkeys "$pkgdir"/usr/share/vboot/devkeys

	install -Dm644 LICENSE -t "$pkgdir"/usr/share/doc/licenses/$pkgname/
}

cgpt() {
	pkgdesc="ChromeOS GPT tool"
	mkdir -p "$subpkgdir"/usr/sbin
	mv "$pkgdir"/usr/bin/cgpt "$subpkgdir"/usr/sbin/
}

sha512sums="
48c0cf858f74cbb0020212ac619ed93ac011530e4f25518e05301f710bb78eba532ee901e79a04d6808122ef589fdf4c6a0f53656350d2f9bf717c588fc795fc  vboot-utils_0~R63-10032.B.orig.tar.gz
64c5e219ea247b1d81a7e8d10ee99fe2d008ee8579bcc41734861a808b9b2c35f889b0732223b85e87052caa712408894b5364f675e1d22fba63a697b27193d3  no-static.patch
"
